//继承工厂
function extend(sub, sup) {
	sub.prototype = Object.create(sup.prototype);
	// 构造函数可枚举的 enumerable ture
	sub.prototype.constructor = sub;

	console.log(Object.getOwnPropertyDescriptor(a.__proto__, 'constructor'))
} 

function extend(sub, sup) {
	sub.prototype = Object.create(sup.prototype);
	// 定义 constructor 不可枚举
	Object.defineProperty(sub.prototype, 'constructor', {
		value: sub,
		enumerable: false
	})
} 

function extend(sub, sup) {
	sub.prototype = Object.create(sup.prototype, {
		constructor: {
			value: sub,
		enumerable: false
		}
	});
} 

 

function A (title) {
	console.log('AAAAA')
	this.title = title
}

A.prototype.show = function() {
	console.log('A show')
}


function B (title) {
	console.log('bbbbb')
	this.title = title
}

B.prototype.show = function() {
	console.log('B show')
}

extend(A, B)

var a = new A('刘阿勇')

console.log(a)

for(var i in a) {
	console.log(i + " : " + a[i])
}

var b = new a.constructor('后盾人')
console.log(b)



console.log('-----------------------------------------\n')

function User(name, age) {
	this.name = name
	this.age = age
}


var user = new User('张三', 33)
console.log(user)

for(var i in user) {
	console.log(i + " : " + user[i])
}


